package com.xy.biz.base.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.base.domain.bo.GoodsBatchBO;
import com.xy.biz.base.domain.po.GoodsBatchPO;
import com.xy.biz.base.domain.query.GoodsBatchQuery;
import com.xy.biz.base.domain.resp.GetGoodsBatchResponse;
import com.xy.biz.base.domain.req.SaveGoodsBatchRequest;
import com.xy.biz.base.domain.req.ListGoodsBatchRequest;

/**
 * 
 * 
 * @author zgy
 * @date 2021-9-22
 */
public class GoodsBatchConverter {
	
	public static GoodsBatchPO toPO(GoodsBatchBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GoodsBatchPO(), true);
	}
	
	public static List<GoodsBatchPO> toPO(Collection<GoodsBatchBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GoodsBatchPO(), true);
	}
	
	public static GoodsBatchBO fromPO(GoodsBatchPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GoodsBatchBO());
	}
	
	public static List<GoodsBatchBO> fromPO(Collection<GoodsBatchPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GoodsBatchBO());
	}
	
	public static GoodsBatchBO toBO(SaveGoodsBatchRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new GoodsBatchBO(), true);
	}
	
	public static List<GoodsBatchBO> toBO(Collection<SaveGoodsBatchRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GoodsBatchBO(), true);
	}
	
	public static GetGoodsBatchResponse toResponse(GoodsBatchBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetGoodsBatchResponse());
	}
	
	public static List<GetGoodsBatchResponse> toResponse(Collection<GoodsBatchBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetGoodsBatchResponse());
	}
	
	public static GoodsBatchQuery toQuery(ListGoodsBatchRequest source) {
		if(null == source) {
			return null;
		}
		GoodsBatchQuery target = new GoodsBatchQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
